<?php

/**
 * Persona filter form base class.
 *
 * @package    sibi-salud
 * @subpackage filter
 * @author     SIBI <sibiud@gmail.com>
 */
abstract class BasePersonaFormFilter extends BaseFormFilterPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'documento_id'     => new sfWidgetFormPropelChoice(array('model' => 'Documento', 'add_empty' => true)),
      'identificacion'   => new sfWidgetFormFilterInput(),
      'nombres'          => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'apellidos'        => new sfWidgetFormFilterInput(array('with_empty' => false)),
      'fecha_nacimiento' => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'email'            => new sfWidgetFormFilterInput(),
      'foto'             => new sfWidgetFormFilterInput(),
      'created_at'       => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
      'updated_at'       => new sfWidgetFormFilterDate(array('from_date' => new sfWidgetFormDate(), 'to_date' => new sfWidgetFormDate())),
    ));

    $this->setValidators(array(
      'documento_id'     => new sfValidatorPropelChoice(array('required' => false, 'model' => 'Documento', 'column' => 'id')),
      'identificacion'   => new sfValidatorPass(array('required' => false)),
      'nombres'          => new sfValidatorPass(array('required' => false)),
      'apellidos'        => new sfValidatorPass(array('required' => false)),
      'fecha_nacimiento' => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'email'            => new sfValidatorPass(array('required' => false)),
      'foto'             => new sfValidatorPass(array('required' => false)),
      'created_at'       => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
      'updated_at'       => new sfValidatorDateRange(array('required' => false, 'from_date' => new sfValidatorDate(array('required' => false)), 'to_date' => new sfValidatorDate(array('required' => false)))),
    ));

    $this->widgetSchema->setNameFormat('persona_filters[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  {
    return 'Persona';
  }

  public function getFields()
  {
    return array(
      'id'               => 'Number',
      'documento_id'     => 'ForeignKey',
      'identificacion'   => 'Text',
      'nombres'          => 'Text',
      'apellidos'        => 'Text',
      'fecha_nacimiento' => 'Date',
      'email'            => 'Text',
      'foto'             => 'Text',
      'created_at'       => 'Date',
      'updated_at'       => 'Date',
    );
  }
}
